package ebusiness.ebusiness.Controllers;

import ebusiness.ebusiness.Dao.UserDao.AdminQueryVO;
import ebusiness.ebusiness.Entity.UserEntity.User;
import ebusiness.ebusiness.Mapper.PathUtil.WebPath;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AdminController {

    @RequestMapping(path = WebPath.AddUSER,method = RequestMethod.POST)
    public String addAUser(String customer_name,String customer_password)throws  Exception{
        try {
            AdminQueryVO adminQueryVO = new AdminQueryVO();
            adminQueryVO.addAUser(customer_name, customer_password);
        }
        catch (Exception e){
            throw e;
        }
        return "1";
    }
    @RequestMapping(path = WebPath.ModifyUSER,method = RequestMethod.POST)
    public String modifyUser(String customer_id,String customer_name,String customer_password) throws Exception{
        int id = Integer.valueOf(customer_id);
        AdminQueryVO adminQueryVO = new AdminQueryVO();
        try {
            adminQueryVO.modifyUser(id,customer_name,customer_password);
        }
        catch (Exception e){
            throw e;
        }
        return "1";
    }
    @RequestMapping(path = WebPath.DeleteUSER,method = RequestMethod.POST)
    public String deleteUser(String customer_id) throws Exception {
        int id = Integer.valueOf(customer_id);
        AdminQueryVO adminQueryVO = new AdminQueryVO();
        try {
            adminQueryVO.deleteUser(id);
        } catch (Exception e) {
            throw e;
        }
        return "1";
    }

}
